package com.muqi.app.qlearn.adapter;

import java.util.List;

import com.easemob.easeui.widget.CircularImage;
import com.muqi.app.network.http.GlideImageUtils;
import com.muqi.app.qlearn.modles.CommentBean;
import com.muqi.app.qlearn.modles.PersonBean;
import com.muqi.app.qlearn.student.R;
import com.muqi.app.user.widget.CircularImageView;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class PersonAdapter extends BaseAdapter {
	private Context context;
	private List<PersonBean> listData;
	private boolean isHome=false;

	public PersonAdapter(Context context, List<PersonBean> listData) {
		this.context = context;
		this.listData = listData;
	}

	@Override
	public int getCount() {
		return listData == null ? 10 : listData.size();
	}

	@Override
	public PersonBean getItem(int position) {
		return listData.get(position);
	}
   
	@Override
	public long getItemId(int position) {
		return position;
	}

	@SuppressLint("InflateParams")
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		final PersonBean itemInfo = listData.get(position);
		if (convertView == null) {
			holder = new ViewHolder();

			convertView = LayoutInflater.from(context).inflate(
					R.layout.item_my_person, null);

			holder.itemAvatar =  (CircularImageView) convertView
					.findViewById(R.id.item_avator);
			holder.itemName = (TextView) convertView
					.findViewById(R.id.item_name);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		
		holder.itemName.setText(itemInfo.name);
		if(itemInfo.avatarInfo!=null){
			GlideImageUtils.setAvatar(context, itemInfo.avatarInfo.fileurl_02, holder.itemAvatar);
		}
		
		return convertView;
	}
	
	private class ViewHolder {
		CircularImageView itemAvatar;
		TextView itemName;
		
	}
}
